package com.devhelper.examples.gef.part;

import java.beans.PropertyChangeEvent;
import java.util.ArrayList;
import java.util.List;

import org.eclipse.draw2d.IFigure;

import com.devhelper.examples.gef.figure.EmployeeFigure;
import com.devhelper.examples.gef.model.Employee;
import com.devhelper.examples.gef.model.Node;

public class EmployeeEditPart extends ExAbstractEditPart {

    @Override
    protected IFigure createFigure() {
        return new EmployeeFigure();
    }

    @Override
    protected void createEditPolicies() {
    }

    @Override
    protected void refreshVisuals() {
        EmployeeFigure figure = (EmployeeFigure) getFigure();
        Employee model = (Employee) getModel();

        figure.setName(model.getName());
        figure.setAge(model.getAge());
        figure.setLayout(model.getLayout());
    }

    @Override
    public List<Node> getModelChildren() {
        return new ArrayList<Node>();
    }

    @Override
    public void propertyChange(PropertyChangeEvent evt) {
        if (evt.getPropertyName().equals(Node.PROPERTY_LAYOUT)) {
            refreshVisuals();
        }
    }
}
